﻿<UserControl x:Class="SoftTeach.View.Datenbank.JahrgangsstufeDetailView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
             xmlns:datenbank="clr-namespace:SoftTeach.ViewModel.Datenbank"
             xmlns:datenbankView="clr-namespace:SoftTeach.View.Datenbank"
             xmlns:scm="clr-namespace:System.ComponentModel;assembly=WindowsBase" mc:Ignorable="d" 
             d:DesignHeight="238" d:DesignWidth="287">
  <UserControl.Resources>
    <CollectionViewSource Source="{Binding Path=Klassenstufen}" x:Key="KlassenstufenSorted">
      <CollectionViewSource.SortDescriptions>
        <scm:SortDescription PropertyName="KlassenstufeBezeichnung"/>
      </CollectionViewSource.SortDescriptions>
    </CollectionViewSource>
  </UserControl.Resources>
  <Grid Grid.Row="1">
    <Grid.ColumnDefinitions>
      <ColumnDefinition Width="150"/>
      <ColumnDefinition Width="*"/>
    </Grid.ColumnDefinitions>
    <Grid Grid.Column="0"  Margin="5">
      <Grid.RowDefinitions>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
      </Grid.RowDefinitions>
      <StackPanel Grid.Row="0" Orientation="Vertical">
        <Label Content="Klassenstufe"/>
        <StackPanel Orientation="Horizontal">
          <Button Name="AddJahrgangsstufeButton" Command="{Binding Path=AddKlassenstufeCommand}" 
                                   Style="{Binding Source={StaticResource {x:Static ToolBar.ButtonStyleKey}}}">
            <StackPanel Orientation="Horizontal">
              <Grid>
                <Image Source="/SoftTeach;component/Images/Jahrgangsstufe32.png"/>
                <Image Source="/SoftTeach;component/Images/AddOverlay32.png"/>
              </Grid>
            </StackPanel>
          </Button>
          <Button Name="RemoveJahrgangsstufeButton" Command="{Binding Path=DeleteKlassenstufeCommand}" 
                                   Style="{Binding Source={StaticResource {x:Static ToolBar.ButtonStyleKey}}}">
            <StackPanel Orientation="Horizontal">
              <Grid>
                <Image Source="/SoftTeach;component/Images/Jahrgangsstufe32.png"/>
                <Image Source="/SoftTeach;component/Images/RemoveOverlay32.png"/>
              </Grid>
            </StackPanel>
          </Button>
        </StackPanel>
      </StackPanel>
      <DataGrid Grid.Row="1" SelectedItem="{Binding Path=CurrentKlassenstufe, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource KlassenstufenSorted}}" AutoGenerateColumns="False" >
        <DataGrid.Columns>
          <DataGridTextColumn Header="Klassenstufen" Binding="{Binding Path=KlassenstufeBezeichnung}" Width="*"/>
        </DataGrid.Columns>
      </DataGrid>
    </Grid>
    <Border Grid.Column="1" Margin="4">
      <ContentControl Content="{Binding Path=CurrentKlassenstufe}">
        <ContentControl.Resources>
          <DataTemplate DataType="{x:Type datenbank:KlassenstufeViewModel}">
            <datenbankView:KlassenstufeDetailView />
          </DataTemplate>
        </ContentControl.Resources>
      </ContentControl>
    </Border>
  </Grid>
</UserControl>
